// 统一管理api接口
import requests from './request'
import mockRequest from './mock'

/**
 * 获取三级联动菜单数据
 * @returns
 */
export const reqCategoryList = () => {
    return requests({
        url: '/product/getBaseCategoryList',
        method: 'GET'
    })
}

/**
 * 获取首页轮播图
 * @returns
 */
export const reqGetBannerList = () => {
    return mockRequest({
        url: '/banner',
        method: 'GET'
    })
}

/**
 * 获取首页floor信息
 * @returns
 */
export const reqFloorList = () => {
    return mockRequest({
        url: '/floor',
        method: 'GET'
    })
}

/**
 * 获取搜索模块数据
 * @returns
 */
export const reqGetSearchInfo = (params) => {
    return requests({
        url: '/list',
        method: 'POST',
        data: params
    })
}

/**
 * 获取产品详情信息
 * @returns
 */
export const reqGoodsInfo = (skuId) => {
    return requests({
        url: `/item/${skuId}`,
        method: 'GET'
    })
}

/**
 * 将产品添加到购物车
 * @returns
 */
export const reqAddToCart = (skuId, skuNum) => {
    return requests({
        url: `/cart/addToCart/${skuId}/${skuNum}`,
        method: 'POST'
    })
}

/**
 * 获取购物车数据
 * @returns
 */
export const reqCartList = () => {
    return requests({
        url: '/cart/cartList',
        method: 'GET'
    })
}

/**
 * 删除购物车商品
 * @returns
 */
export const reqDeleteCartById = (skuId) => {
    return requests({
        url: `/cart/deleteCart/${skuId}`,
        method: 'DELETE'
    })
}

/**
 * 更改商品是否选中状态
 * @returns
 */
export const reqCheckCartById = (skuId, isChecked) => {
    return requests({
        url: `/cart/checkCart/${skuId}/${isChecked}`,
        method: 'GET'
    })
}

/**
 * 获取验证码
 * @returns
 */
export const reqGetCode = (phone) => {
    return requests({
        url: `/user/passport/sendCode/${phone}`,
        method: 'GET'
    })
}

/**
 * 注册
 * @returns
 */
export const reqUserRegister = (data) => {
    return requests({
        url: '/user/passport/register',
        method: 'POST',
        data
    })
}

/**
 * 登录
 * @returns
 */
export const reqUserLogin = (data) => {
    return requests({
        url: '/user/passport/login',
        method: 'POST',
        data
    })
}

/**
 * 获取用户信息【携带token】
 * @returns
 */
export const reqGetUserInfo = () => {
    return requests({
        url: '/user/passport/auth/getUserInfo',
        method: 'GET'
    })
}

/**
 * 退出登录
 * @returns
 */
export const reqLogout = () => {
    return requests({
        url: '/user/passport/logout',
        method: 'GET'
    })
}

/**
 * 获取用户地址信息
 * @returns
 */
export const reqAddressInfo = () => {
    return requests({
        url: '/user/userAddress/auth/findUserAddressList',
        method: 'GET'
    })
}

/**
 * 获取用户交易页信息
 * @returns
 */
export const reqOrderInfo = () => {
    return requests({
        url: '/order/auth/trade',
        method: 'GET'
    })
}

/**
 * 提交订单
 * @returns
 */
export const reqSubmitOrder = (tradeNo, data) => {
    return requests({
        url: `/order/auth/submitOrder?tradeNo=${tradeNo}`,
        method: 'POST',
        data
    })
}

/**
 * 获取订单支付信息
 * @returns
 */
export const reqPayInfo = (orderId) => {
    return requests({
        url: `/payment/weixin/createNative/${orderId}`,
        method: 'GET'
    })
}

/**
 * 获取订单支付状态
 * @returns
 */
export const reqPayStatus = (orderId) => {
    return requests({
        url: `/payment/weixin/queryPayStatus/${orderId}`,
        method: 'GET'
    })
}

/**
 * 获取我的订单列表
 * @returns
 */
export const reqMyOrderList = (page, limit) => {
    return requests({
        url: `/order/auth/${page}/${limit}`,
        method: 'GET'
    })
}
